﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Routing;

namespace JQMdotNet
{
    public static class JQMUtilities
    {
        #region utils
        private static string _jqmnamespace;
        private static string _nsadd = "";

        public static string JQMNamespace
        {
            get{return _jqmnamespace;}
            set
            {
                _jqmnamespace = value;
                if(String.IsNullOrEmpty(value))
                    _nsadd = value + "-";
            }
        }

        public static void AddRole(this IDictionary<string,object> htmlAttributes, string role)
        {
            htmlAttributes.ReplaceAttibute("role", role);
        }

        public static void ReplaceDataAttribute(this IDictionary<string,object> htmlAttributes, string attr, string value)
        {
            htmlAttributes.ReplaceAttibute("data-"+_nsadd+value, value);
        }

        public static void ReplaceAttibute(this IDictionary<string,object> htmlAttributes, string attr, object value)
        {
            htmlAttributes.Remove(attr);
            htmlAttributes.Add(attr, value);
        }

        public static void AddClass(this IDictionary<string,object> htmlAttributes, string Class)
        {
            if (htmlAttributes.ContainsKey("class"))
                htmlAttributes.Add("class", Class);
            else
                ReplaceAttibute(htmlAttributes, "class", ((string)htmlAttributes["class"]) + " " + Class);
        }
        #endregion
    }
    public enum TransistionType
    {
        Default = 0,
        fade,
        pop,
        flip,
        turn,
        flow,
        slidefade,
        slide,
        slideup,
        slidedown,
        none
    }
}